import 'package:dirver/pages/detail/index.dart';
import 'package:dirver/pages/home/index.dart';
import 'package:dirver/pages/login.dart';
import 'package:dirver/pages/not_found.dart';
import 'package:fluro/fluro.dart';

class Routes {
  // 路由
  static const String home = '/';
  static const String login = '/login';
  static const String detail = '/detail/:id';

  // Handler
  static final Handler _homeHandler = Handler(handlerFunc: (context, parameters) => HomePage());
  static final Handler _loginHandler = Handler(handlerFunc: (context, parameters) => LoginPage());
  static final Handler _detailHandler = Handler(handlerFunc: (context, parameters) => 
    DetailPage(id: parameters['id']!.first));
  

  // 配置路由
  static void configureRoutes(FluroRouter router) {
    router.define(home, handler: _homeHandler);
    router.define(login, handler: _loginHandler);
    router.define(detail, handler: _detailHandler);
    router.notFoundHandler = Handler(handlerFunc: (context, parameters) => NotFoundPage());
  }
}